"The request failed. The underlying connection was closed: Could not establish trust relationship for the SSL\/TLS secure channel."

Hello,

Can someone please tell me the solution for this issue. I am trying to connect to my exchange server and its throwing this error. I have also imported the certificate and placed in root folder. But still find the same error. Going craxy from 3 days plz someone help me.Here is my code:

  public string CheckAvailability(string value)
        {
            try
            {
                //ServicePointManager.ServerCertificateValidationCallback = CertificateValidationCallBack;

                //Connecting to EWS by using the EWS Managed API 2.0
                ExchangeService service = new ExchangeService(ExchangeVersion.Exchange2010);

                // Connect by using the default credentials of the authenticated user.
                //service.UseDefaultCredentials = true;

                // Connect by using the credentials of user
                service.Credentials = new NetworkCredential("UID", "PWD", "Domain");

                service.TraceEnabled = true;
                service.TraceFlags = TraceFlags.All;   

                // Use Autodiscover to set the URL endpoint.You should either set the URL explicitly or call AutodiscoverUrl, but you should not do both.
                service.Url = new Uri("https://ad-lab/ews/Services.asmx");
             

                //EmailMessage msg = new EmailMessage(service);
                //msg.ToRecipients.Add(new EmailAddress("xyz@domain.com "));
                //msg.Subject = "Test email";
                //msg.Body = new MessageBody(BodyType.HTML, "<p>Hello Email!</p>");
                //msg.Send();
                GetUserFreeBusy(service);
                return "Hello " + value;

            }
            catch (Exception ex)
            {
                return ex.Message;
            }
            finally { }
        }

Thanks,

Sravani

May 5th, 2015 5:05pm

I disabled the SSL on the client but now its throwing me a different error:

"The request failed. The remote server returned an error: (405) Method Not Allowed."

Can somebody tell me whats going on.

Thanks,

Srav

Free Windows Admin Tool Kit Click here and download it now
May 5th, 2015 6:05pm

Are you sure you are in the right forum? This is for Forefront Identity Manager and this sounds more like an Exchange or C# problem. While many folks here are proficient in both you might be better served in a different forum.

Anyhow, it sounds like the cert may not be in the correct certificate store. Under what security context are you running your code? Is it Network Service? Is it a specific user account?

If the first then the cert needs to be in the Trusted Certificate Authority folder in the Local Computer Store. If the second then it needs to be in the same folder but in the Store for that user.

May 5th, 2015 8:39pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics